<!DOCTYPE html>
<html lang="en">
<head>
	{{template "pc/public/mycss.html" .}}
<style type="text/css">
	#wrapper{
		background: #f5f5f5!important;
	}
	.header-center{
		background: #fff;
	}
	.user_left{
		background: #fff;
	}
	.fenlei{
		width: 20%;
	}
	
	@media (max-width: 992px){
		.fenlei{
		    width: 100%;
		}
	}
  .recharge #content>div p select {
    padding: 5px 10px;
    border: 1px solid #eee;
    border-radius: 5px;
    box-shadow: inset 0 0 5px #eee;
    width: 200px;
}
</style>
<body class="common-home res layout-home1 recharge">
<div id="wrapper" class="wrapper-full banners-effect-7">
	<!-- Header Container  -->
	{{template "pc/public/head.html" .}}
    {{template "pc/public/mytop.html" .}}
	<div class="main-container container">
		<div class="row mb-50">
			<!--Left Part Start -->
		{{template "pc/public/myleft.html" .}}
			<!--Middle Part Start-->
			<div id="content" class="col-md-10 col-sm-8 right mt-15">
        <p class="hd">余额提现</p>   
        <div>
          <p><span>真实姓名：</span><input type="text" placeholder="请输入您的真实姓名" name="name"></p>
          <p><span>收款账号：</span><input type="number" placeholder="请输入您的收款账号" name="account"></p>
          <p><span>提现金额：</span><input type="number" placeholder="请输入您要提现的金额" name="money"></p>
          <p><span>提现密码：</span><input type="password" placeholder="请输入您的提现密码" name="cashpassword"></p>
          <p><span>提现银行：</span>
          <select name="bank">
            {{range .bank}}
            <option value="{{.id}}">{{.name}}</option>
            {{end}}
          </select></p>
          <button class="sure">提现</button>
        </div>
        <p class="desc">Tip：建议您前往统采微信公众平台或App进行提现操作</p>
      </div>
		</div>
	</div>
</div>

{{template "pc/public/foot.html" .}}
{{template "pc/public/myfoot.html" .}}
<script type="text/javascript" src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/js/card.js"></script>
</body>
</html>
<script type="text/javascript">
  var havepass=0
  {{if .info.cashpassword}}
  {{if ne .info.cashpassword ""}}
  havepass=1
  {{end}}
  {{end}}
  window.onload=function(){
    if(havepass==0){
      // document.getElementsByClassName('recharge')[0].style.display="none"
      wxc.xcConfirm("您还未设置提现密码,前往设置吗?","confirm",{onOk:function(){
        window.location.href="/my/password?type=cash"
      },
      onCancle:function(){
        history.go(-1)
      }}); 
    }
  }
  var money={{.info.money}};
  $('.sure').click(function(){
    if(parseInt($('input[name="money"]').val())<=parseInt({{.system.cash}})){
      showToast("一次需要提现{{.system.cash}}元以上~"); return false;
    }
    if(parseInt($('input[name="money"]').val())>parseInt(money)){
      showToast("余额不足~"); return false;
    }
    if($('input[name="name"]').val()==""){
      showToast("请输入账户名字"); return false;
    }
    if($('input[name="cashpassword"]').val()==""){
      showToast("请输入提现密码"); return false;
    }
    if($('input[name="account"]').val().length!=16&&$('input[name="account"]').val().length!=19){
      showToast("卡号位数错误"); return false;
    }else{
      if(!luhmCheck(form.account)){
        showToast("卡号未通过校验,请检查~"); return false;
      }
    }
    var form=$('form').serialize()
    var that=this
    that.disabled=true
    $.ajax({
      url:window.location.href,
      type:'post',
      data:form,
      dataType:'json',
      timeout:10000,
      success: function(data){
      if (data==1) {
        wxc.xcConfirm("提交成功，请等待审核","info",{onClose:function(){
          window.location.href=document.referrer
        }});
      }else if(data==2){
        showToast("余额不足~")
      }else if(data==3){
        showToast("密码错误~");
      }else if(data==4){
        showToast("您需要预留{{.system.shopcash}}元");
      }else{
        showToast("网络繁忙，请重试~");
      }
      that.disabled=false
      }
    })
  })
</script>